<br/>
<?php echo $html->link(__('Add module'), '/admin/modules/add',array('class'=>'add_button'));
?>
<?php 
$editorMessage = __("Enable module editor");
$target = "__blank";
if($session->read("Module.moduleEditor") == true)
{
	$target = "";
	$editorMessage = __("Disable module editor");
}
//temporary disabled
//echo "  ".$html->link($editorMessage,array('action'=>"toggleEditorMode"),array('class'=>'add_button')).'<br />';
?>

<?php 
$index->setData($modules, 'Module');
$index->setAction(__("Edit"), '/admin/modules/edit/:Module.id');
$index->showFields(ClassRegistry::getObject('Module')->getFields('group','index'));
$index->setAction(__("Delete"), '/admin/modules/delete/:Module.id',$this->helpers,__('Are you sure, you want to delete this module ?'));
$index->sortableFields(array('id','title','section','status'));
$index->setAction(null,null,$this->helpers,false,true,'publish_unpublish');
echo $index->display();

function publish_unpublish($model,$record)
{
	if($record[$model]['status'] == Module::PUBLISHED)
	{
		$action['title'] = __('Unpublish');
		$action['url'] = '/admin/modules/changeStatus/'.$record[$model]['id'];
		$action['confirmMessage'] = __('Are you sure, you want to unpublish this module ?');
	} else {
		$action['title'] = __('Publish');
		$action['url'] = '/admin/modules/changeStatus/'.$record[$model]['id'];
	}
	return $action;
}
?>